<?php
class mysql{
	public $database;
	public $server_name;
	public $server_password;
	public $id;
	function mysql(){
	$this->server_name="root";
	$this->server_password="";
	}
	function link($database){
	     if ($database==""){
		$this->database="bbs_database";
	     }else{
		$this->database=$database;
		}
    if($id=mysql_connect("localhost",$this->server_name,$this->server_password)){
         if(!mysql_select_db($this->database,$id)){
      	   echo "数据库连接错误";
      	   exit;
         }
         mysql_query("set names utf8");
      }
	}

    function excu($query){
     if($result=mysql_query($query)){
     	return $result;
      }else{
      	echo "sql语句执行错误";
      	exit;
      }
    }
	}
   ?>
